package com.evildog.workspace.system.application.convert;

import com.evildog.workspace.dependencies.mybatis.object.LinkIdDTO;
import com.evildog.workspace.system.application.bo.MenuPermissionBO;
import com.evildog.workspace.system.application.bo.MenuPermissionTreeBO;
import com.evildog.workspace.system.application.dto.MenuEditPermissionDTO;
import com.evildog.workspace.system.application.entity.MenuPermission;
import com.evildog.workspace.system.application.model.MenuPermissionCreateParam;
import com.evildog.workspace.system.application.model.MenuPermissionUpdateApiParam;
import com.evildog.workspace.system.application.model.MenuPermissionUpdateParam;
import com.evildog.workspace.system.application.vo.MenuPermissionTreeVO;
import com.evildog.workspace.system.application.vo.MenuPermissionVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface MenuPermissionConvert {

    MenuPermissionConvert INSTANCE = Mappers.getMapper(MenuPermissionConvert.class);

    MenuEditPermissionDTO convert(MenuPermissionCreateParam menuPermissionCreateParam);

    MenuEditPermissionDTO convert(MenuPermissionUpdateParam param);


    @Mapping(target = "isDeleted", ignore = true)
    MenuPermission convert(MenuEditPermissionDTO menuEditPermissionDTO);

    MenuPermissionVO convert(MenuPermissionBO menuPermissionBO);

    MenuPermissionBO convert(MenuPermission menuPermission);

    List<MenuPermissionTreeVO> convertVoList(List<MenuPermissionTreeBO> menuPermissionTreeBO);

    @Mappings({
            @Mapping(target = "label",source = "name")
    })
    MenuPermissionTreeBO convertTree(MenuPermission menuPermissionListDO);


    @Mapping(target = "linkIds", source = "apiPermissions")
    LinkIdDTO convert(MenuPermissionUpdateApiParam param);

    List<MenuPermissionBO> convertBoList(List<MenuPermission> menuPermissions);

}